  /***********************************************************************************************
 * @Author: Jone                                                       
 * @Created Date:03/02/2010
 * @Functionality: ajax until to handle cascading menu
 * @Version: 1.0
 * **********************************************************************************************/

/**
 * @Created Date:03/02/2010
 * @Functionality: Create XMLHttpRequest Object 
 * @Modified Date:
 * @Modified Person:
 * **/



var XMLHttpReq;      
var dropdownListTag;
    function createXMLHttpRequest() {   
        if(window.XMLHttpRequest) { //Mozilla Browser   
            XMLHttpReq = new XMLHttpRequest();   
        }   
        else if (window.ActiveXObject) { // IE Browser  
            try {   
                XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");   
            } catch (e) {   
                try {   
                    XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");   
                } catch (e) {}   
            }   
        }   
    }   
    /**
     * @Created Date:03/02/2010
     * @Functionality: send request function
     * @Modified Date:
     * @Modified Person:
     * **/
    
    function sendRequest(url) {   
        createXMLHttpRequest();   
        XMLHttpReq.open("GET", url, true);   
        XMLHttpReq.onreadystatechange = processResponse;//give response function
        XMLHttpReq.send(null);  // send request
    }   

    /**
     * @Created Date:03/02/2010
     * @Functionality:The function is handle return information 
     * @Modified Date:
     * @Modified Person:
     * **/
    function processResponse() {   
        if (XMLHttpReq.readyState == 4) { //  check object status   
            if (XMLHttpReq.status == 200) { // handle the information if response successful   
                updateMenu();   
            } else { //page is exception 
                  alert("your request has exception");   
            }   
        }   
    }   
    
    /**
     * @Created Date:03/02/2010
     * @Functionality: function of updating menu 
     * @Modified Date:
     * @Modified Person:
     * **/
    
    function updateMenu() {   
     
        var xmlDoc =XMLHttpReq.responseXML.documentElement;
        var xsel = xmlDoc.getElementsByTagName("select");
        var subRoot = document.getElementById(dropdownListTag);
        subRoot.options.length=0;
        for(var i=0;i<xsel.length;i++){
        	 
             try{
            	 var xValue=xsel[i].childNodes[0].firstChild.nodeValue;
                 var xText=xsel[i].childNodes[1].firstChild.nodeValue;
                 var option=new Option(xText,xValue);
                 subRoot[i]=option;
             }catch(e){
            	 xValue = "";
            	 var xText=xsel[i].childNodes[1].firstChild.nodeValue;
                 var option=new Option(xText,xValue);
                 subRoot[i]=option;
             }
        }

        
    }   
    /**
     * @Created Date:03/02/2010
     * @Functionality: function of creating cache menu
     * @Modified Date:
     * @Modified Person:
     * **/
    function showSubMenu(url,component,tagType) {   
    	dropdownListTag=tagType;
    	var idValue = component.options[component.selectedIndex].value;
        
        sendRequest(url+"?idValue="+idValue);   
    }
     
     /**
      * @Created Date:03/02/2010
      * @Functionality: function of creating cache menu
      * @Modified Date:
      * @Modified Person:
      * **/
     function  option_select(url,element,skillBranchId){   
         var   i;  
         for   (i=0;i<element.length;i++){   
                 if(element.options[i].selected   ==   true){   
                 	  element.title = element.options[i].innerHTML;  
              }     
         } 
         
         showSubMenu(url,element,skillBranchId);
         
         var sel = document.getElementById("skillBranch");
         
         sel.Value = "";     
     } 

